<?php

use yii\db\Migration;

class m170606_060545_create_art_teaching extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->createTable('{{%art_teaching}}',[
                'id' => $this->primaryKey()->notNull().' COMMENT \'自增id\'',
                'title' => $this->string(50)->defaultValue(null).' COMMENT \'标题\'',
                'type' => $this->smallInteger(3)->defaultValue(0).' COMMENT \'类型 1 益智  2 音乐  3  形体\'',
                'class_time' => $this->string(50)->defaultValue(null) .' COMMENT \'上课时间\'',
                'price' => $this->decimal(10,2)->defaultValue(0.00) .' COMMENT \'价格\'',
                'class_count' => $this->smallInteger(6)->defaultValue(0) .' COMMENT \'课次\'',
                'arrangemant_ids' => $this->string(50)->defaultValue(null).' COMMENT \'关联复课id\'',
                'created_at' => $this->integer(11)->defaultValue(0).' COMMENT \'添加时间\'',
            ]);
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v){
            $this->db = $v;
            $this->dropTable('{{%art_teaching}}');
        }
    }
}
